package cn.changein.framework.kernel.model.exception;

import lombok.Getter;
import lombok.Setter;

/**
 * <p>
 *     远程接口调用出现的业务异常
 * </p>
 *

 * @Date: 2020-10-27 15:06
 * @Copyright: companyName
 * @Version 1.0
 * @Since JDK1.8
 */
@Getter
@Setter
public abstract class ApiServiceException extends Exception {

    /**
     * 错误编码
     */
    private Integer code;

    /**
     * 错误的提示信息
     */
    private String errorMessage;

    /**
     * 默认用于dubbo反序列化
     */
    public ApiServiceException() {

    }

    public ApiServiceException(AbstractBaseExceptionEnum exception) {
        super(exception.getMessage());
        this.code = exception.getCode();
        this.errorMessage = exception.getMessage();
    }

    /**
     * 获取异常的类的具体名称
     */
    public String getExceptionClassName() {
        return this.getClass().getName();
    }
}
